package com.alibaba.nacos.config.server.jpa.utils;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

/**
 * The type of nacos-all.
 *
 * @author 问道于盲
 * @date 2020-03-09
 */
public class DateUtils {

    public static LocalDateTime convert(Date date) {
       return date.toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
    }

    public static Timestamp convert(LocalDateTime date) {
        long epochMilli = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        return new Timestamp(epochMilli);
    }

    public static long convertMilli(LocalDateTime date) {
        return LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }
}
